﻿/*****************************************************************************/
/**
 *	\file	inquire.cpp
 *	\author	Xavier
 *	\date	2023/05/07
 *	\version	1.0
 *	\brief	查询功能
 *	\note	Copyright (c) 2020-2030 南京理工大学
 *	\remarks	无
 ******************************************************************************/
#include "head.h"

void inquire(CMgr *mgrobj)
{
    assert(NULL != mgrobj);
    char inquire_choice;
    cout << "房间信息查询请按1, 顾客信息查询请按2: " << endl;
Again002:
    inquire_choice = inputChar();
    if (inquire_choice == '1')
    {
        int j, k = 0;
        cout << endl;
        cout << "下列房间还没人预订，也没人入住：" << endl;
        for (j = 0; j < 80; j++)
        {
            if (mgrobj->room[j].state == 0)
            {
                if (k % 10 == 0)
                    cout << endl;
                cout << mgrobj->room[j].number << '\t';
                k++;
            }
        }
        cout << endl;
        cout << endl;
        k = 0;
        cout << "下列房间已预订：" << endl;
        for (j = 0; j < 80; j++)
        {
            if (mgrobj->room[j].state == 1)
            {
                if (k % 10 == 0)
                    cout << endl;
                cout << mgrobj->room[j].number << '\t';
                k++;
            }
        }
        k = 0;
        cout << endl;
        cout << endl;
        cout << "下列房间有人入住：" << endl;
        for (j = 0; j < 80; j++)
        {
            if (mgrobj->room[j].state == 2)
            {
                if (k % 10 == 0)
                    cout << endl;
                cout << mgrobj->room[j].number << '\t';
                k++;
            }
        }
        cout << endl;
        cout << endl;
    }
    else if (inquire_choice == '2')
    {
        cout << "按姓名查询请按1, 按身份证查询请按2: " << endl;
    Again003:
        char inquire_choice = inputChar();
        if (inquire_choice == '1')
        {
            char name3[10];
            cout << "请输入顾客的姓名: " << endl;
            inputStr(name3, sizeof(name3));
            for (int j = 0; j < mgrobj->i; j++)
            {
                if (strcmp(mgrobj->customer[j]->get_name(), name3) == 0)
                {
                    cout << name3 << "的住房信息如下:\n";
                    cout << '\t' << "房间号为: " << mgrobj->customer[j]->get_room_number() << endl;
                    cout << "\t"
                         << "预付房费为: " << mgrobj->customer[j]->get_prepaid() << endl;
                }
                else
                {
                    cout << '\t' << "未找到相关信息\n";
                }
            }
        }
        else if (inquire_choice == '2')
        {
            char id3[20];
            cout << "请输入顾客的身份证号: " << endl;
            inputStr(id3, sizeof(id3));
            for (int j = 0; j < mgrobj->i; j++)
            {
                if (strcmp(mgrobj->customer[j]->get_ID(), id3) == 0)
                {
                    cout << mgrobj->customer[j]->get_name() << "的住房信息如下:\n";
                    cout << '\t' << "房间号为: " << mgrobj->customer[j]->get_room_number() << endl;
                    cout << "\t"
                         << "预付房费为: " << mgrobj->customer[j]->get_prepaid() << endl;
                }
                else
                {
                    cout << '\t' << "未找到相关信息\n";
                }
            }
        }
        else
        {
            cout << "请输入1或2：" << endl;
            goto Again003;
        }
    }
    else
    {
        cout << "请输入1或2：" << endl;
        goto Again002;
    }
}